import { ref } from 'vue';

export function useTableMixin() {
  const toggleAllCheckboxes = (tableData, isAllChecked) => {
    tableData.forEach(item => {
      item.checked = isAllChecked;
    });
  };

  const toggleRowCheckbox = (tableData, item) => {
    item.checked = !item.checked;
  };

  const getSelectedIds = (tableData) => {
    return tableData
      .filter(item => item.checked)
      .map(item => item.id);
  };

  const hasSelectedItems = (tableData) => {
    return tableData.some(item => item.checked);
  };

  const resetSelection = (tableData) => {
    tableData.forEach(item => {
      item.checked = false;
    });
  };

  return {
    toggleAllCheckboxes,
    toggleRowCheckbox,
    getSelectedIds,
    hasSelectedItems,
    resetSelection
  };
} 